#include <iostream>
#include <vector>
using namespace std;

void QuickSort(vector<int>& arr, int left, int right)
{
	if (left >= right)
	{
		return;
	}
	int begin = left, end = right;
	int key = arr[left];
	int cur = left + 1;
	while (cur <= right)
	{
		if (arr[cur] > key)
		{
			swap(arr[cur], arr[right--]);
		}
		else if (arr[cur] < key)
		{
			swap(arr[cur++], arr[left++]);
		}
		else
		{
			cur++;
		}
	}
	QuickSort(arr, begin, left - 1);
	QuickSort(arr, right + 1, end);
}

int main()
{
	vector<int> arr = { 6,1,4,9,8,7,2,0,5,3 };
	QuickSort(arr, 0, arr.size() - 1);
	for (auto& e : arr)
	{
		cout << e << ' ';
	}
	return 0;
}